﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Pixysoft.BarCode
{
    class JAN13
    {
        private static volatile JAN13 instance;

        private static object syncRoot = new Object();

        public static JAN13 Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new JAN13();
                        }
                    }
                }
                return instance;
            }
        }

        public string GetBarCode(string barcode)
        {
            if (!barcode.StartsWith("49")) throw new Exception("EJAN13-1: Invalid Country Code for JAN13 (49 required)");

            if (!Pixysoft.NumberCoder.Instance.IsInt64(barcode))
                throw new Exception("EJAN13-2: Numeric Data Only");

            return EAN13.Instance.GetBarCode(barcode);
        }

    }
}
